package com.restaurant.application.minifacade.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;

import java.util.List;

public class PathData implements PickableBean {

    public static final String FN_ACTIONPATH = "actionPath";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_ACTIONPATH);
    
    private String actionPath;

    public PathData(String actionPath) {
        setActionPath(actionPath);
    }

    public PathData() {
    }

    public PathData duplicate() {
        PathData result = new PathData();
        result.actionPath = this.actionPath;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public String getActionPath() {
        return actionPath;
    }

    public void setActionPath(String value) {
        this.actionPath = value;
    }

    public PathData withActionPath(String value) {
        setActionPath(value);
        return this;
    }

    public PathData withActionPath(String value, String defaultValue) {
        setActionPath(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch (name) {
            case "actionPath":
                return getActionPath();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof PathData)) return false;
        return signature().equals(((PathData) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean PathData has no signature defined, no hash code or equals possible.");
    }
}
